<h1>Create New Task</h1>

<?php // include_partial('task_form', array('form' => $form)) ?>

<script type="text/javascript">
	function openDialogue(method) {
		switch(method) {
		case 'map':
			location.href = '<?php $sf_user->setAttribute('testattr', 'hello world'); echo url_for('@select_location_from_map'); ?>';
			break;
		case 'poi':
			location.href = '<?php $sf_user->setAttribute('testattr', 'hello world'); echo url_for('@select_location_from_poi'); ?>';
			break;
		case 'favourites':
			alert('going to open fav page');
			break;
		}
	}
</script>
<?php echo link_to('Task List', '@task_list_view'); ?>
<form action="<?php echo url_for('@task_create')?>" method="post">
<table width="75%" border="1">
	<tr>
		<td>Name</td>
		<td><input name="name" type="text" id="name2" maxlength="255"></td>
	</tr>
	<tr>
		<td>Type</td>
		<td><select name="type_id" size="1" id="select2">
		<?php foreach($task_types as $task_type): ?>
			<option value="<?php echo $task_type->getId(); ?>>"><?php echo $task_type->getName(); ?></option>
			<?php endforeach ?>
		</select></td>
	</tr>
	<tr>
		<td>Description</td>
		<td><textarea name="description" cols="30" rows="3" id="textarea"></textarea></td>
	</tr>
	<tr>
		<td>Location</td>
		<td><select name="locationMethod" size="1" id="locationMethod"
			onchange="openDialogue(this.value)">
			<option value="None" selected>-Select Location-</option>
			<option value="map">Map</option>
			<option value="poi">POI</option>
			<option value="favourites">Favourites</option>
		</select>
<?php
if($sf_user->hasAttribute('task_location')) {
	$location = $sf_user->getAttribute('task_location');
	echo 'Lat: '. $location->getLatitude() .' Lng: '. $location->getLongitude();
}
?>
		
		</td>
	</tr>
	<tr>
		<td>Priority</td>
		<td><select name="priority_id" size="1" id="select3">
		<?php foreach($task_priorities as $task_priority): ?>
			<option value="<?php echo $task_priority->getId(); ?>>"><?php echo $task_priority->getName(); ?></option>
			<?php endforeach ?>
		</select></td>
	</tr>
	<tr>
		<td>Due Date and Time</td>
		<td><input type="Text" name="duedatetime" size="25" maxlength="25"
			id="duedatetime"> <a
			href="javascript: NewCssCal('duedatetime','ddmmyyyy','dropdown',true,12)">
		<img width="16" height="16" alt="Pick a date"
			src="/lbreminder/web/images/cal.gif"> </a></td>
	</tr>
</table>
<p><input type="submit" name="Submit" value="Save"></p>
</form>
